package cn.djb.day11;

import cn.djb.day2.ListNode;

class Solution_1 {

    public ListNode deleteNode(ListNode head, int val) {
        if (head.val == val) {
            return head.next;
        }
        ListNode tmp = head;
        while (tmp.next != null) {
            ListNode next = tmp.next;
            if (next.val == val) {
                tmp.next = tmp.next.next;
                break;
            }
            tmp = next;
        }

        return head;
    }
}